﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HML.Design
{
    /// <summary>
    /// 自定义颜色面板
    /// </summary>
    public partial class AlphaColorEditorCustomColorDialogForm : Form
    {
        #region 字段

        private const int WM_NCHITTEST = 0x84;
        private const int HTCLIENT = 0x01;
        private const int HTCAPTION = 0x02;
        private const int WM_NCLBUTTONDBLCLK = 0xA3;

        #endregion

        public AlphaColorEditorCustomColorDialogForm()
        {
            InitializeComponent();
        }

        #region 重写

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_NCHITTEST:  //鼠标点任意位置后可以拖动窗体
                    {
                        this.DefWndProc(ref m);
                        if (m.Result.ToInt32() == HTCLIENT)
                        {
                            m.Result = new IntPtr(HTCAPTION);
                        }
                        break;
                    }
                case WM_NCLBUTTONDBLCLK:  //禁止双击最大化
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }

        #endregion

        #region 私有方法

        private void saveButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }

        private void cancleButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        #endregion 
    }
}
